package app.framework.controller.base;

import app.framework.component.Sequencer;
import app.framework.security.LocalUserDetails;
import com.jfinal.kit.JsonKit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.stereotype.Controller;

/**
 * Created by gkatzioura on 9/2/16.
 */
@Controller
public class BaseController {
	@Autowired protected  Sequencer sequencer;

	protected UserDetails getCurrentUser() {
		Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        return (LocalUserDetails) principal;
	}

	protected  String toJson(Object obj){
		return JsonKit.toJson(obj);
	}
}
